package com.shujia.util;

import java.io.BufferedReader;
import java.io.FileReader;

/**
 * @author shujia
 */
public class FileUtil {
    /**
     * 读取文件
     * @param path 文件路径
     * @return 文件中内容
     */
    public static String readFile(String path) {
        StringBuilder stringBuilder = new StringBuilder();
        try {
            //创建字符输入流
            FileReader fileReader = new FileReader(path);
            //创建缓冲输入流
            BufferedReader bufferedReader = new BufferedReader(fileReader);
            //读取一行
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                //将每一行拼接到字符串的后面
                stringBuilder.append(line);
                stringBuilder.append("\n");
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        String sql = readFile("trip/ods/cdc/ods_kafka_activity.sql");
        System.out.println(sql);
    }
}
